package com.company.action;

import com.company.service.PageProjectService;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

public class PageProjectAction extends BaseAction {

    @Autowired
    PageProjectService pageProjectService;

    @RequestMapping(value = "project_findAll")
    public String execute(@RequestParam Integer page, Model model) throws Exception {

        int PageMaxnum = pageProjectService.queryPageNum();
        if (pageNum > PageMaxnum) {
            return SUCCESS;
        }
        ServletActionContext.getRequest().getSession()
                .setAttribute("PageMaxnum", PageMaxnum);
        ServletActionContext.getRequest().getSession()
                .setAttribute("ProList", pageProjectService.query(pageNum));
        return super.execute();
    }

}
